package org.aurora.framework.boot.mybatis.flex.processor.utils;
import org.yaml.snakeyaml.Yaml;

import java.io.InputStream;
import java.util.Optional;

/**
 * name: YamlUtil
 * <p>
 * desc:
 * </p>
 * create date: 2024-10-09 18:19:24
 *
 * @author cao.yong
 */
public class YamlUtil {

    private static final Yaml yaml = new Yaml();

    public static <T> Optional<T> load(InputStream ins, Class<T> clazz) {
        if (ins == null) {
            return Optional.empty();
        } else {
            return Optional.of(yaml.loadAs(ins, clazz));
        }
    }
}
